home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performCopyCurrentUVSet.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.2 KB  |  148 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. proc setOptionVars (int $forceFactorySettings)
  18. {               
  19.     if ($forceFactorySettings || !`optionVar -exists polyCopyUVSet`)
  20.         optionVar -stringValue polyCopyUVSet "uvSet";
  21. }
  22.  
  23. global proc performCopyCurrentUVSetSetup (string $parent, 
  24.                                          int $forceFactorySettings)
  25. {
  26.     setOptionVars($forceFactorySettings);
  27.     setParent $parent;
  28.  
  29.     string $sval;
  30.     $sval = `optionVar -query polyCopyUVSet`;
  31.     textFieldGrp -edit -tx $sval polyCopyUVSet;
  32. }
  33.  
  34. global proc performCopyCurrentUVSetCallback (string $parent, int $doIt, string $selectCmd)
  35. {
  36.     setParent $parent;
  37.  
  38.     optionVar -stringValue polyCopyUVSet
  39.         `textFieldGrp -query -tx polyCopyUVSet`;
  40.  
  41.     if ($doIt) {
  42.         string $cmd = ("performCopyCurrentUVSet \"1\" {\"0\", \"" + $selectCmd + "\", \"0\"} \"\"");
  43.         eval ($cmd);
  44.         addToRecentCommandQueue $cmd "copyCurrentUVSet";
  45.     }
  46. }
  47.  
  48. proc polyCopyCurrentUVSetOptions(string $selectCmd)
  49. {
  50.     string $commandName = "performCopyCurrentUVSet";
  51.     string $callback = ($commandName + "Callback");
  52.     string $setup = ($commandName + "Setup");
  53.        
  54.     string $layout = getOptionBox();
  55.     setParent $layout;
  56.     setUITemplate -pushTemplate DefaultTemplate;
  57.     waitCursor -state 1;
  58.  
  59.     string $parent = `columnLayout -adjustableColumn true`;
  60.     
  61.     textFieldGrp -label "UV Set Name to Copy to: " polyCopyUVSet;
  62.  
  63.     setParent $parent;
  64.  
  65.     waitCursor -state 0;
  66.     setUITemplate -popTemplate;
  67.        
  68.     string $applyBtn = getOptionBoxApplyBtn();
  69.     button -edit -label "Apply and Close"
  70.            -command ($callback + " " + $parent + " " + 1 + " \"" + $selectCmd + "\"")
  71.         $applyBtn;
  72.  
  73.     string $saveBtn = getOptionBoxSaveBtn();
  74.     button -edit 
  75.         -command ($callback + " " + $parent + " " + 0 + " \"" + $selectCmd + "\"" + "; hideOptionBox")
  76.         $saveBtn;
  77.  
  78.     string $resetBtn = getOptionBoxResetBtn();
  79.     button -edit 
  80.         -command ($setup + " " + $parent + " " + 1)
  81.         $resetBtn;
  82.              
  83.     setOptionBoxTitle("Copy Current UV Set Options");
  84.  
  85.     setOptionBoxHelpTag( "CopyCurrentUVSet" );
  86.  
  87.     eval (($setup + " " + $parent + " " + 0));      
  88.     showOptionBox();
  89. }
  90.  
  91. global proc string performCopyCurrentUVSet 
  92.     (string $version, string $args[], string $uvSetName)
  93. //
  94. //    Input Arguments:
  95. //    $version: The version of this option box.  Used to know how to 
  96. //    interpret the $args array.
  97. //        "1" : $action, $selectCmd
  98. //
  99. //    $args
  100. //    Version 1
  101. //    [0]        $action        0 : Execute the command.
  102. //                        1 : Show the option box dialog.
  103. //                        2 : Return the command.
  104. //    [1]        $selectCmd    The command to issue to determine which objects
  105. //                            to affect
  106. //    [2]        $forceCreate    Whether or not to force creation of a new UV set
  107. //
  108. //  Return Value:
  109. //      The string to execute for this option box.
  110. //
  111. {
  112.     int        $versionNum                = $version;
  113.  
  114.     int        $action                    = $args[0];
  115.     string    $selectCmd                = $args[1];
  116.     int        $forceCreate            = $args[2];
  117.  
  118.     string $cmd="polyUVSet -copy -newUVSet ";
  119.     switch ($action) 
  120.     {
  121.       case 1: polyCopyCurrentUVSetOptions $selectCmd;
  122.         // Just the option box
  123.         break;
  124.         
  125.       case 0:
  126.       case 2:
  127.         setOptionVars(false);
  128.         string $name = `optionVar -query polyCopyUVSet`;
  129.         if ($forceCreate) $name = $uvSetName;
  130.  
  131.         if (size($name))
  132.         {
  133.             $cmd = ("{string $objects[] = `" + $selectCmd + "`;" + $cmd);
  134.             $cmd += ("\"" + $name + "\" $objects;}");
  135.             if ($action == 0) {
  136.                 evalEcho $cmd;
  137.             }
  138.         }
  139.         else
  140.         {
  141.             if ($action == 0) 
  142.                 warning "No name specified to copy uvset with.";
  143.         }
  144.         break;
  145.     }
  146.     return $cmd;
  147. }
  148.